package com.springsecurity.utlis;

import com.springsecurity.domain.User;

/**
 * <h3>Spring-Security</h3>
 * <p></p>
 *
 * @author gdw
 * @since 2024-07-12 09:17:51
 */
public class AdministratorThreadLocal {
    private static ThreadLocal<User> administratorThreadLocal = new ThreadLocal<>();

    public static void setAdministrator(User sysUser) {
        administratorThreadLocal.set(sysUser);
    }

    public static User getAdministrator() {
        return administratorThreadLocal.get();
    }

    public static void removeAdministrator() {
        administratorThreadLocal.remove();
    }

    public static String getAdministratorName(){
        return administratorThreadLocal.get().getUsername();
    }
}
